package com.gadberry.utility.expression.function;

import java.util.List;

import com.gadberry.utility.algorithm.Algorithm;
import com.gadberry.utility.expression.Argument;
import com.gadberry.utility.expression.Expression;
import com.gadberry.utility.expression.Function;
import com.gadberry.utility.expression.InvalidArgumentsException;

/**
 * This class is the basis for zero argument constructs e.g. ELSE, WEND, REPEAT and
 * it always returns a Boolean argument set to false.
 *  
 * @author Peter Lager
 *
 */
public abstract class FalseFunction extends Function {

	public FalseFunction(Expression expression) {
		super(expression);
	}

	@Override
	public Argument resolve(Algorithm algor) {
		return new Argument(new Boolean(false), getResolver());
	}
	
	@Override
	protected void checkArgs(List<Argument> args)
			throws InvalidArgumentsException {
		String canonicalName = this.getClass().getCanonicalName();
		if (args.size() > 0) {
			throw new InvalidArgumentsException(
					canonicalName + " requires a single argument.  Wrong number of arguments provided.");
		}
	}
}
